<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册</title>
    <link rel="stylesheet" href="./css/reset.css">
    <link rel="stylesheet" href="./css/public.css">
    <link rel="stylesheet" href="./css/login.css">
</head>

<body>
    <!-- 注册 -->
    <div class="login-box">
        <h3>
            <p class="float_left">欢迎加入</p>
            <img src="./images/fila_blue_150.png" alt="" class="float_left">
        </h3>
        <input type="text" class="phone" placeholder="手机号码">
        <span id="errey"></span>
        <div class="verify_code">
            <input type="password" class="verify" placeholder="输入密码字母开头6-18位"><span class="verify_t"></span>
            <input type="password" class="verifyOk" placeholder="确认密码"><span class="verify_b"></span>
        </div>
        <input type="checkbox" class="choice" checked="checkbox">我已充分阅读，理解并接受隐私政策的全部内容

        <button class="btn">确认</button>
        <div class="member">
            <a href="">已是会员？</a>
            <a href="/home.html">立即登录</a>
        </div>
    </div>
    <!-- 底部 -->
    <div id="foot">
        <div class="foot-wrap">
            <ul class="float_left">
                <li><a href="">购物服务</a></li>
                <li><a href="">关于品牌</a></li>
                <li><a href="">查找门店</a></li>
                <li>关注FLIA官方媒体:
                    <a href="" class="microblog"></a>
                    <a href="" class="WeChat"></a>
                </li>
                <li>售后服务电话：400-886-7699</li>
            </ul>
            <div class="foot_right float_right">
                <p>©FILA体育 闽ICP备11020421号-8 闽公网安备35020302033807号</p>
                <p>©2020 FILA Luxembourg S.à.r.l. - All Rights Reserved -</p>
            </div>
        </div>
    </div>
    <div class="service">
        <a href="">客服</a>
    </div>
    <div id="tisi">
        注册成功
    </div>
    <script src="./js/jquery.min.js"></script>
    <script>
        $(function () {
            let errey = $("#errey")
            let phone = $(".phone")
            // 手机号
            phone.blur(function () {
                let reNum = /^(1)\d{10}$/
                if (reNum.test(phone.val())) {
                    errey.html("合格")
                    errey.css({ color: "#03234c", fontSize: "14px" })
                }
                else {
                    errey.html("×请输入正确电话号码")
                    errey.css({ color: "red", fontSize: "14px" })
                }
            })
            // 密码
            let verify = $(".verify")
            let paw = $(".verify_t")
            verify.blur(function () {
                let leval = /^[A-z0-9-=+,.]{6,18}$/
                if (leval.test(verify.val())) {
                    paw.html("合格")
                    paw.css({ color: "#03234c" })
                }
                else {
                    paw.html("×请输入正确的密码")
                    paw.css({ color: "red", fontSize: "14px" })
                }
            })
            let verifyOk = $(".verifyOk")
            let verofy_b = $(".verify_b")
            verifyOk.blur(function () {
                if (verify.val() === verifyOk.val()) {
                    verofy_b.html("合格")
                    verofy_b.css({ color: "#03234c", fontSize: "14pxmefq" })
                }
                else {
                    verofy_b.html("×请输入正确的密码")
                    verofy_b.css({ color: "red", fontSize: "14px" })

                }
            })
            $(".btn").click(function () {
                // alert(1)
                let tel = $(".phone").val()
                // console.log(phone)
                let paw = $(".verify").val()
                $.ajax({
                    url: "http://127.0.0.1:81/userData",
                    data: {
                        tel: tel
                    },
                    success: function (data) {
                        // console.log(data)
                        let newData = JSON.parse(data)
                        if (newData.length === 0) {
                            $("#tisi").show()
                            setInterval(function(){
                                $("#tisi").fadeOut()
                            },1000)
                            $("#tisi").html("注册成功")
                            $.ajax({
                                url: "http://127.0.0.1:81/addData",
                                data: {
                                    tel: tel,
                                    paw: paw
                                }
                            })
                        }
                        else{
                            $("#tisi").show()
                            setInterval(function(){
                                $("#tisi").fadeOut()
                                
                            },1000)
                            $("#tisi").html("注册失败")
                            
                        }
                    }

                })




            })
        })
    </script>
</body>

</html>